﻿using System.Diagnostics;

namespace ECommon
{
    /// <summary>
    /// 线程工具
    /// </summary>
    public static partial class ProcessTool
    {
        /// <summary>
        /// 判断某个进程是否在运行启动
        /// </summary>
        /// <param name="processName">进程名</param>
        /// <returns>判断结果</returns>
        public static bool IsProcessRunning(string processName)
        {
            //创建进程对象获取本地计算机的所有进程
            Process[] process = Process.GetProcessesByName(processName);
            //判断是否有相同名称的进程，得到的进程数大于0则表示该进程正在运行
            return process != null && process.Length > 0;
        }
    }
}
